package com.csc.controller;

import com.csc.dto.BookParam;
import com.csc.entity.Book;
import com.csc.service.BookService;
import org.apache.ibatis.annotations.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 86130
 * @version 1.0
 * @description: 图书控制器
 * @date 2025/6/16 下午2:47
 */
@RestController
@RequestMapping("/book")
public class BookController {
    @Autowired
    BookService bookService;
    //获取书籍列表
    @RequestMapping("/list")
    public List<Book> list(@RequestBody BookParam bookParam){
        return bookService.list(bookParam);
    }

    //添加书籍
    @RequestMapping("/add")
    public int add(@RequestBody Book book){
        return bookService.add(book);
    }

    //修改书籍
    @RequestMapping("/update")
    public int update(@RequestBody Integer bookID){
        return bookService.update(bookID);
    }

    //删除书籍
    @RequestMapping("/delete")
    public int delete(@RequestBody Integer bookID){
        return bookService.delete(bookID);
    }
}
